﻿Public Class frmGenerateOptions
    Public Sub New(files() As String)
        InitializeComponent()
        AddControls(files)
    End Sub

    Private Sub frmGenerateOptions_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Me.Icon = My.Resources.Main

    End Sub

    Private Sub AddControls(files() As String)
        Dim uc As ucFile

        For Each f As String In files
            uc = New ucFile
            uc.lblFileName.Text = f
            pnlFiles.Controls.Add(uc)
        Next

    End Sub

    Private Sub cmdOK_Click(sender As Object, e As EventArgs) Handles cmdOK.Click
        Dim files As New List(Of String)
        Dim gains As New List(Of Single)
        Dim stretches As New List(Of Single)
        Dim offsets As New List(Of Integer)

        For Each uc As ucFile In pnlFiles.Controls
            files.Add(uc.lblFileName.Text)
            gains.Add(uc.txtScaleVolume.Value / 100)
            stretches.Add(uc.txtScaleTime.Value / 100)
            offsets.Add(CInt(uc.txtWaveformOffset.Value))
        Next

        ' Prompt for image file name to save
        If dlgSaveImage.ShowDialog = DialogResult.OK Then
            My.Settings.LastSaveImage = dlgSaveImage.FileName
            BassFunctions.CreateWaveformImage(files.ToArray, dlgSaveImage.FileName, gain:=gains.ToArray, stretch:=stretches.ToArray, offset:=offsets.ToArray)
            Process.Start(dlgSaveImage.FileName)

        End If
    End Sub

    Private Sub cmdCancel_Click(sender As Object, e As EventArgs) Handles cmdCancel.Click
        Me.Close()
    End Sub

End Class